package com.fengmi.mapper;

import com.fengmi.entity.StatOrder;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author 123
 * @Date 2022/2/10 11:21
 * @Version 1.0
 */

/**
 * 订单统计mapper
 */
public interface StatOrderMapper {
    //查询昨日订单的日期，订单总数，订单总金额
    @Select("SELECT \n" +
            "DATE_FORMAT(create_time,'%Y-%m-%d') AS sta_dat,\n" +
            "SUM(pay_amount) AS sta_amount,\n" +
            "COUNT(*) AS sta_cunt\n" +
            "FROM oms_order")
    public StatOrder findTotalForYesterday();

    //统计订单信息后往记录表中插入
    @Insert("insert into stat_order (sta_dat,sta_amount,sta_cunt) values" +
            "(#{staDat},#{staAmount},#{staCunt})")
    public int saveOrderTotalInfo(StatOrder statOrder);

    //查询订单统计表的信息，用户echarts的图标展示
    public List<StatOrder> statOrderByDate(@Param("beginTime") String beginTime,@Param("endTime") String endTime);
}
